Repository navigation
fix: sign a new token request when a retry replays the nonce - #749
theluckystrike wants to merge 1 commit into
Conversation
A token request that a fallback host retries is sent with the same nonce. When the server used that nonce on an attempt whose response was lost, it rejects the retry with 40105. request_token now signs a new token request and sends it once more in that case, when the library made the nonce. Fixes ably#710
|
No actionable comments were generated in the recent review. WalkthroughWhen a key-signed token request receives error 40105, ChangesToken request nonce retry
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk:
|
Fixes #710
I took option 2 from the issue, the retry at the auth layer.
Http.make_requestserialises the body once and sends the same bytes to each fallback host. If the firstrequestTokenattempt reaches the server and the response is lost, the retry carries the same nonce and the server rejects it with40105 Nonce value replayed.request_tokennow catches a40105from the token request POST and, when the library signed the request with the key, signs a new token request (new nonce, new MAC) and sends it once more. The retry does not apply when:auth_callbackorauth_url(those are not invoked again)nonceormacin the token paramshttp.pyand the RSC15 fallback logic do not change.Tests
test/unit/token_request_nonce_test.pyuses a mock endpoint that uses each nonce one time only and loses the first response. On mainrequest_token()fails with40105. With the fix it gets the token after 2 distinct nonces.uv run pytest test/unit test/uts/rest/unit test/uts/realtime/unit(1650 passed) anduv run ruff checkpass.Summary by CodeRabbit